package com.fyt.algorithm.Leecode.day4;

/**
 * 11. 盛最多水的容器
 */
public class MaxArea {
    public static int maxArea(int[] height) {
       int left=0,right=height.length-1;
       int res=0;
       while (left<right){
           int cur=(right-left)*Math.min(height[left],height[right]);
           res=Math.max(res,cur);
           if(height[left]<=height[right]) left++;
           else right--;

       }

        return res;
    }

    public static void main(String[] args) {
        int [] height={1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(height));

    }
}
